import {HttpVerificationCode} from '../../public/http'
import { ElMessage} from 'element-plus'

export const useLandlord = () => {
	
	const cards = [
		'clubs1','clubs2','clubs3','clubs4','clubs5','clubs6',
		'clubs7','clubs8','clubs9','clubs10','clubs11','clubs12','clubs13',
		'diamonds1','diamonds2','diamonds3','diamonds4','diamonds5','diamonds6',
		'diamonds7','diamonds8','diamonds9','diamonds10','diamonds11','diamonds12','diamonds13',
		'hearts1','hearts2','hearts3','hearts4','hearts5','hearts6',
		'hearts7','hearts8','hearts9','hearts10','hearts11','hearts12','hearts13',
		'spades1','spades2','spades3','spades4','spades5','spades6',
		'spades7','spades8','spades9','spades10','spades11','spades12','spades13',
		'king','kinglet'
		]
	const cardsCompare = ['king','kinglet','2','1','13','12','11','10','9','8','7','6','5','4','3'] //从大到小
	// 随机顺序排序
	const randomCards = ()=>{
		
		let cardsAssign = Object.assign([],cards)
		cardsAssign.sort(()=>Math.random() - 0.5)
		let sliceResult = sliceArray(cardsAssign,17)
		sliceResult = [['clubs1','clubs2','hearts3','clubs4','clubs5','clubs6','clubs7','clubs8','clubs9','clubs10','clubs11','clubs12','clubs13','spades2','diamonds2','hearts2'],
			['diamonds4','hearts2','diamonds6','diamonds7','spades9','diamonds9','diamonds10','diamonds11','diamonds12','diamonds13','clubs3','diamonds5','hearts3','hearts4','hearts5','hearts6','hearts7'],
			['hearts8','hearts9','hearts10','hearts11','hearts12','hearts13','spades1','spades2','spades3','spades9','clubs9','spades6','spades7','spades8','diamonds8','spades10','spades11'],
			['spades13','king','kinglet']
		]
		return {
			sliceResult:sliceResult,
		}
	}
	// 按照正确顺序排序
	const reorderCards = (card:string[],sort:any)=>{
		let cardsArray = Object.assign([],card)
		let cardsCompareCopy = Object.assign([],cardsCompare)
		let newCards = [] as string[]
		let cardsCompareArray:string[] = !sort?cardsCompareCopy:cardsCompareCopy.reverse()
		cardsCompareArray.forEach((v:string,n)=>{
			cardsArray.forEach((s:string,i:number)=>{
				let a = s
				if(a.indexOf('clubs') > -1){
					a = a.slice(5)
				}else if(a.indexOf('diamonds') > -1){
					a = a.slice(8)
				}else if(s.indexOf('hearts') > -1 || a.indexOf('spades') > -1){
					a = a.slice(6)
				}
				if(a === v){
					newCards.push(s)
				}
			})
		})
		
		return newCards
		
	}
	// 比较是否大于对方的牌
	const compareCards = (myCard:string[],otherCard:string[],isTip:boolean = false,name:string)=>{
		let {newArray:myNewCard} = stringCardsSwitchIndex(myCard)
		let {newArray:otherNewCard} = stringCardsSwitchIndex(otherCard)
		let isPassInspect = [] as any
		let numberText = '' as any
		let cardsCount = otherCard.length
		if(name === '单牌'){
			myNewCard.forEach((m:number,i:number)=>{
				if(m < otherNewCard[0]){
					isPassInspect.push(myCard[i])
				}
			})
			isPassInspect = sliceArray(reorderCards(isPassInspect,true),1)
		}else if(name === '对子'){
			let repeatArray = separateSeachRepeatSort(myCard,2)
			repeatArray.forEach((m:string,i:number)=>{
				numberText = seachNumber(m,true)
				if(cardsCompare.indexOf(numberText) < otherNewCard[0]){
					isPassInspect.push(m)
				}
			})
			isPassInspect = sliceArray(isPassInspect,2)
		}else if(name === '王炸'){
			
			
		}else if(name === '三张不带'){
			let repeatArray = separateSeachRepeatSort(myCard,3)
			repeatArray.forEach((m,i)=>{
				numberText = seachNumber(m,true)
				if(cardsCompare.indexOf(numberText) < otherNewCard[0]){
					isPassInspect.push(m)
				}
			})
			isPassInspect = sliceArray(isPassInspect,3)
		}else if(name === '炸弹'){
			let repeatArray = separateSeachRepeatSort(myCard,4)
			repeatArray.forEach((m,i)=>{
				numberText = seachNumber(m,true)
				if(cardsCompare.indexOf(numberText) < otherNewCard[0]){
					isPassInspect.push(m)
				}
			})
			isPassInspect = sliceArray(isPassInspect,4)
		}else if(name === '三带一'){
			let repeatArray = separateSeachRepeatSort(myCard,3)
			repeatArray.forEach((m,i)=>{
				numberText = seachNumber(m,true)
				if(cardsCompare.indexOf(numberText) < otherNewCard[0]){
					isPassInspect.push(m)
				}
			})
			if(isPassInspect.length > 0){
				let repeatOneArray = separateSeachRepeatSort(myCard,1)
				let isPassInspectSlice = sliceArray(isPassInspect,3)
				let newMakeArray = [] as any
				repeatOneArray.forEach((m:string,i:number)=>{
					isPassInspectSlice.forEach((v:string[])=>{
						newMakeArray = newMakeArray.concat(v)
						newMakeArray.push(m)
					})
				})
				isPassInspect = newMakeArray
			}
			isPassInspect = sliceArray(isPassInspect,4)
		}else if(name === '三带二'){
			let repeatArray = separateSeachRepeatSort(myCard,3)
			repeatArray.forEach((m,i)=>{
				numberText = seachNumber(m,true)
				if(cardsCompare.indexOf(numberText) < otherNewCard[0]){
					isPassInspect.push(m)
				}
			})
			if(isPassInspect.length > 0){
				let repeatOneArray = separateSeachRepeatSort(myCard,2)
				let isPassInspectSlice = sliceArray(isPassInspect,3)
				let repeatOneArraySlice = sliceArray(repeatOneArray,2)
				let newMakeArray = [] as any
				repeatOneArraySlice.forEach((m:string[],i:number)=>{
					isPassInspectSlice.forEach((v:string[])=>{
						newMakeArray = newMakeArray.concat(v)
						newMakeArray = newMakeArray.concat(m)
					})
				})
				isPassInspect = newMakeArray
			}
			isPassInspect = sliceArray(isPassInspect,5)
		}else if(name === '四带二'){
			let repeatArray = separateSeachRepeatSort(myCard,4)
			repeatArray.forEach((m,i)=>{
				numberText = seachNumber(m,true)
				if(cardsCompare.indexOf(numberText) < otherNewCard[0]){
					isPassInspect.push(m)
				}
			})
			if(isPassInspect.length > 0){
				// 寻找对子
				let repeatOneArray = separateSeachRepeatSort(myCard,2)
				let isPassInspectSlice = sliceArray(isPassInspect,4)
				let repeatOneArraySlice = sliceArray(repeatOneArray,2)
				let newMakeArray = [] as any
				let repeatOtherTwoArray = separateSeachRepeatSort(otherCard,2)
				if(repeatOtherTwoArray.length > 0){
					isPassInspectSlice.forEach((v:string[])=>{
						repeatOneArraySlice.forEach((m:string[])=>{
							newMakeArray = newMakeArray.concat(v)
							newMakeArray = newMakeArray.concat(m)
						})
					})
					isPassInspect = newMakeArray
				}else{
					// 寻找单个
					let oneMakeArray = [] as any
					repeatOneArray = separateSeachRepeatSort(myCard,1)
					if(repeatOneArray.length > 0){
						repeatOneArray.forEach((v:string)=>{
							repeatOneArray.forEach((m:string)=>{
								if(v!=m){
									oneMakeArray.push(v)
									oneMakeArray.push(m)
								}
							})
						})
						repeatOneArraySlice = sliceArray(oneMakeArray,2)
						isPassInspectSlice.forEach((v:string[])=>{
							repeatOneArraySlice.forEach((m:string[])=>{
								newMakeArray = newMakeArray.concat(v)
								newMakeArray = newMakeArray.concat(m)
							})
						})
						isPassInspect = newMakeArray
					}
				}
			}
			isPassInspect = sliceArray(isPassInspect,6)
		}else if(name === '连对'){
			
			let repeatArray = separateSeachRepeatSort(myCard,2)
			let maxIndex = -1
			for(let i = 0;i < repeatArray.length;i++){
				numberText = seachNumber(repeatArray[i],true)
				if(cardsCompare.indexOf(numberText) < otherNewCard[0]){
					maxIndex = i
					break
				}
			}
			if(maxIndex !== -1){
				repeatArray = repeatArray.slice(maxIndex)
				if(repeatArray.length >= cardsCount){
					let newMakeArray = [] as any
					repeatArray.forEach((v:string,i:number)=>{
						newMakeArray[i] = []
						for(let j = i;j < cardsCount;j++){
							newMakeArray[i].push(repeatArray[j])
						}
					})
					let newMakeArraySlice = newMakeArray
					newMakeArraySlice.forEach((v:string[])=>{
						if(v.length === cardsCount){
							let {value:cancelRepeatArray} = cancelRepeat(v)
							if(isStraight(cancelRepeatArray)){
								isPassInspect = isPassInspect.concat(v)
							}
						}
					})
				}
			}
			isPassInspect = sliceArray(isPassInspect,cardsCount)
		}else if(name === '顺子'){
			
			let repeatArray = separateSeachRepeatSort(myCard,1)
			let maxIndex = -1
			for(let i = 0;i < repeatArray.length;i++){
				numberText = seachNumber(repeatArray[i],true)
				if(cardsCompare.indexOf(numberText) < otherNewCard[0]){
					maxIndex = i
					break
				}
			}
			if(maxIndex !== -1){
				repeatArray = repeatArray.slice(maxIndex)
				
				if(repeatArray.length >= cardsCount){
					let {value:cancelRepeatArray} = cancelRepeat(repeatArray)
					let newMakeArray = [] as any
					cancelRepeatArray.forEach((v:string,i:number)=>{
						newMakeArray[i] = []
						for(let j = i;j < cardsCount;j++){
							newMakeArray[i].push(cancelRepeatArray[j])
						}
					})
					let newMakeArraySlice = newMakeArray
					newMakeArraySlice.forEach((v:string[])=>{
						if(v.length === cardsCount && isStraight(v)){
							isPassInspect = isPassInspect.concat(v)
						}
					})
				}
			}
			isPassInspect = sliceArray(isPassInspect,cardsCount)
		}else if(name === '飞机'){
			let repeatArray = separateSeachRepeatSort(myCard,3)
			let repeatOtherArray = separateSeachRepeatSort(otherCard,3)
			let maxIndex = -1
			for(let i = 0;i < repeatArray.length;i++){
				numberText = seachNumber(repeatArray[i],true)
				if(cardsCompare.indexOf(numberText) < otherNewCard[0]){
					maxIndex = i
					break
				}
			}
			if(maxIndex !== -1){
				repeatArray = repeatArray.slice(maxIndex)
				cardsCount = repeatOtherArray.length
				if(repeatArray.length >= cardsCount){
					let newMakeArray = [] as any
					repeatArray.forEach((v:string,i:number)=>{
						newMakeArray[i] = []
						for(let j = i;j < cardsCount;j++){
							newMakeArray[i].push(repeatArray[j])
						}
					})
					
					let newMakeArraySlice = newMakeArray
					newMakeArraySlice.forEach((v:string[])=>{
						if(v.length === cardsCount){
							let {value:cancelRepeatArray} = cancelRepeat(v)
							if(isStraight(cancelRepeatArray)){
								isPassInspect = isPassInspect.concat(v)
							}
						}
					})
					isPassInspect = sliceArray(isPassInspect,cardsCount)
					let twoArray = separateSeachRepeatSort(myCard,2)
					let oneArray = separateSeachRepeatSort(myCard,1)
					
					
					let repeatTwoArray = separateSeachRepeatSort(otherCard,2)
					let repeatOneArray = separateSeachRepeatSort(otherCard,1)
					console.log('飞机',twoArray,oneArray,repeatTwoArray,repeatOneArray)
					if(twoArray.length >= repeatTwoArray.length && oneArray.length >= repeatOneArray.length){
						let sliceTwoLength = repeatTwoArray.length
						let sliceOneLength = repeatOneArray.length
						let twoArraySlice = sliceArray(twoArray,sliceTwoLength)
						let oneArraySlice = sliceArray(oneArray,sliceOneLength)
						let newCompareCards = [] as any
						// 分三种情况,21都有,22,11三种
						if(sliceTwoLength === 0){
							twoArraySlice = []
						}else if(sliceOneLength === 0){
							oneArraySlice = []
						}
						if(sliceTwoLength > 0 && sliceOneLength > 0){
							twoArraySlice.forEach((v:string[])=>{
								oneArraySlice.forEach((m:string[])=>{
									if(v.length === sliceTwoLength && m.length === sliceOneLength){
										newCompareCards = newCompareCards.concat(v)
										newCompareCards = newCompareCards.concat(m)
									}
								})
							})
						}else if(sliceTwoLength > 0 && sliceOneLength === 0){
							twoArraySlice.forEach((v:string[])=>{
								if(v.length === sliceTwoLength){
									newCompareCards = newCompareCards.concat(v)
								}
							})
						}else if(sliceTwoLength === 0 && sliceOneLength > 0){
							console.log('oneArraySlice',oneArraySlice)
							oneArraySlice.forEach((m:string[])=>{
								if(m.length === sliceOneLength){
									newCompareCards = newCompareCards.concat(m)
								}
							})
						}
						
						if(newCompareCards.length > 0){
							let newCompareCardsSlice = sliceArray(newCompareCards,(sliceTwoLength+sliceOneLength))
							let lastCompareCards = [] as any
							isPassInspect.forEach((v:string[])=>{
								newCompareCardsSlice.forEach((m:string[])=>{
									if(m.length === (sliceTwoLength+sliceOneLength)){
										lastCompareCards = lastCompareCards.concat(v)
										lastCompareCards = lastCompareCards.concat(m)
									}
								})
							})
							isPassInspect = sliceArray(lastCompareCards,otherCard.length)
							
							console.log('isPassInspect',isPassInspect)
						}else{
							isPassInspect = []
						}
					}else{
						isPassInspect = []
					}
					
					// if(!isTip){
					// 	let twoArray = separateSeachRepeatSort(myCard,2)
					// 	let oneArray = separateSeachRepeatSort(myCard,1)
					// 	let {size} = cancelRepeat(twoArray)
						
					// 	if(size + oneArray.length !== cardsCount/3){
					// 		let repeatOtherArraySlice = sliceArray(repeatOtherArray,3)
					// 		 if(repeatOtherArraySlice.length === 2 && cardsCount/3!=twoArray.length){
					// 			 isPassInspect = []
					// 		 }
					// 		 if(repeatOtherArraySlice.length > 2){
					// 			 isPassInspect = []
					// 		 }
					// 	}
					// }
					
				}
				
			}
		}
		if(isPassInspect.length === 0){
			if(isTip){
				if(name === '炸弹'){
					if(myCard.indexOf('king') > -1&&myCard.indexOf('kinglet') > -1){
						isPassInspect = [['king','kinglet']]
					}
				}else if(name !== '炸弹' && name !== '王炸'){
					let repeatArray = separateSeachRepeatSort(myCard,4)
					if(repeatArray.length > 0){
						isPassInspect = repeatArray
					}
					isPassInspect = sliceArray(isPassInspect,4)
					if(myCard.indexOf('king') > -1&&myCard.indexOf('kinglet') > -1){
						isPassInspect.push(['king','kinglet'])
					}
				}
			}else{
				if(name !== '炸弹' && name !== '王炸'){
					let repeatArray = separateSeachRepeatSort(myCard,4)
					if(repeatArray.length > 0){
						isPassInspect = repeatArray
					}
					isPassInspect = sliceArray(isPassInspect,4)
					if(myCard.indexOf('king') > -1&&myCard.indexOf('kinglet') > -1){
						isPassInspect.push(['king','kinglet'])
					}
				}else if(name === '炸弹'){
					if(myCard.indexOf('king') > -1&&myCard.indexOf('kinglet') > -1){
						isPassInspect.push(['king','kinglet'])
					}
				}
			}
			
			
		}
		return isPassInspect
	}
	// 字符串数组转下标比较大小
	const stringCardsSwitchIndex = (card:string[])=>{
		let cardsArray = [] as number[]
		let numberIndex = '' as any
		let index = -1 as number
		card.forEach((v:string,i:number)=>{
			numberIndex = seachNumber(v,true)
			index = cardsCompare.indexOf(numberIndex)
			cardsArray.push(index)
		})
		return {
			newArray:cardsArray,
			oldArray:card
		}
	}
	// 检测是否符合规则
	const isConformTo = (card:string[])=>{
		let length = card.length
		let isPassInspect = false as any
		let cardCopy = Object.assign([],card)
		if(length === 1){
			isPassInspect = isPassInspect = {
					name:'单牌',
					value:card
				}
		}else if(length === 2){
			let {size:resultLength} = cancelRepeat(cardCopy)
			if(resultLength === 1){
				isPassInspect = {
					name:'对子',
					value:card
				}
			}else if(cardCopy[0] === 'king' && cardCopy[1] === 'kinglet' || cardCopy[0] === 'kinglet' && cardCopy[1] === 'king'){
				isPassInspect = {
					name:'王炸',
					value:card
				}
			}
		}else if(length === 3){
			let {size:resultLength} = cancelRepeat(cardCopy)
			if(resultLength === 1){
				isPassInspect = {
					name:'三张不带',
					value:card
				}
			}
		}else if(length === 4){
			let {size:resultLength} = cancelRepeat(cardCopy)
			if(resultLength === 1){
				isPassInspect = {
					name:'炸弹',
					value:card
				}
			}else{
				if(seachNumber(cardCopy[0]) === seachNumber(cardCopy[1]) && seachNumber(cardCopy[0]) === seachNumber(cardCopy[2])){
					 isPassInspect = {
						name:'三带一',
						value:card
					 }
				}
				
			}
			
		}else if(length === 5){
			let {size:resultLength} = cancelRepeat(cardCopy)
			if(resultLength == 2 && seachNumber(cardCopy[0])===seachNumber(cardCopy[2])){
				isPassInspect = {
					name:'三带二',
					value:card
				}
			}
		}else if(length === 6){
			let c = seachNumber(cardCopy[0])
			if(c===seachNumber(cardCopy[1])&&c===seachNumber(cardCopy[2])&&c===seachNumber(cardCopy[3])){
				isPassInspect = {
					name:'四带二',
					value:card
				}
			}
		}
		// 顺子
		if(length >= 5){
			let {size:resultLength,value:data} = cancelRepeat(cardCopy)  as any
			if(isStraight(data) && resultLength >= 3){
				if(cardCopy.length/2 === resultLength){
					isPassInspect = {
						name:'连对',
						value:card
					}
				}else if(resultLength === cardCopy.length){
					isPassInspect = {
						name:'顺子',
						value:card
					}
				}
			}
			if(length >= 6){
				let result = separateSeachRepeatSort(cardCopy,3)
				let resultTwo = separateSeachRepeatSort(cardCopy,2)
				let resultOne = separateSeachRepeatSort(cardCopy,1)
				let {size:resultSize,value:resultValue} = cancelRepeat(result)  as any
				let {size:resultTwoSize,value:resultTwoValue} = cancelRepeat(resultTwo)  as any
				let flage = result.length/3 === resultSize && isStraight(resultValue)
				if( flage && (resultTwoSize+resultOne.length) === resultSize || flage&&(resultTwoSize+resultOne.length) === 0 || flage&&result.length/3 === 2&&resultTwoSize === 1&&resultOne.length === 0){
					isPassInspect = {
						name:'飞机',
						value:card
					}
				}
			}
		}
		return isPassInspect
	}
	// 返回对应的数字
	const seachNumber = (text:string,isKing:boolean = false)=>{
		if(text){
			if(text.indexOf('clubs') > -1){
				text = text.slice(5)
			}else if(text.indexOf('diamonds') > -1){
				text = text.slice(8)
			}else if(text.indexOf('hearts') > -1 || text.indexOf('spades') > -1){
				text = text.slice(6)
			}
		}
		
		return isKing?text:Number(text)?Number(text):-1
	}
	// 检测是否是顺子
	const isStraight = (card:string[])=>{
		let count = 0
		let cardsCompareArray = Object.assign([],cardsCompare)
		cardsCompareArray = cardsCompareArray.reverse()
		let isContinuous = false
		let before = 0  as any
		let after = 0  as any
		let {newArray} = stringCardsSwitchIndex(card)
		for (let i = 0; i < card.length; i++) {
			before = seachNumber(card[i - 1])
			after = seachNumber(card[i])
			if(before === 1 && newArray.indexOf(2) === -1){
				before = 14
			}
			if(after === 1 && newArray.indexOf(2) === -1){
				after = 14
			}
			if(after - before === 1){
				count += 1
			}
			
			if(count>(card.length-2)){ 
				isContinuous = true
			}else{
				isContinuous = false
			}
		}
		return isContinuous
		
	}
	// 找出重复值,并且按照重复值数量和大小排序,例如:333,222,1
	const seachRepeatSort = (card:string[])=>{
		let repeatArray = [] as string[]
		let cardCopy = Object.assign([],card)
		let cardOtherCopy = Object.assign([],card)
		let recordArray = []  as string[]
		for(let k = 4; k > 0;k--){
			// 统计多个重复数字和单个数字
			let separateArray = [] as string[]
			for (let i = 0; i < cardCopy.length; i++) {
				let count = 0
				let cardCopyValue = seachNumber(cardCopy[i],true) as any
				recordArray = []
				if(separateArray.indexOf(cardCopy[i]) === -1){
					for(let j = 0; j < cardOtherCopy.length; j++){
						let cardOtherCopyValue = seachNumber(cardOtherCopy[j],true) as any
						if(cardCopyValue === cardOtherCopyValue){
							count++	
							recordArray.push(cardOtherCopy[j])
						}
						if(j === cardOtherCopy.length - 1 && count === k){
							separateArray = separateArray.concat(recordArray)
						}
					}
				}
			}
			let result = reorderCards(separateArray,true)
			repeatArray = repeatArray.concat(result)
		}
		return repeatArray
		
	}
	// 单独寻找指定个数,比如3个相同的,四个相同的
	const separateSeachRepeatSort = (card:string[],k:number)=>{
		let repeatArray = [] as string[]
		let cardCopy = Object.assign([],card)
		let cardOtherCopy = Object.assign([],card)
		// 统计多个重复数字和单个数字
		let separateRealArray = [] as string[]
		let recordArray = []  as string[]
		for (let i = 0; i < cardCopy.length; i++) {
			let count = 0
			let cardCopyValue = seachNumber(cardCopy[i],true) as any
			recordArray = []
			if(separateRealArray.indexOf(cardCopy[i]) === -1){
				for(let j = 0; j < cardOtherCopy.length; j++){
					let cardOtherCopyValue = seachNumber(cardOtherCopy[j],true) as any
					if(cardCopyValue === cardOtherCopyValue){
						count++	
						recordArray.push(cardOtherCopy[j])
					}
					if(j === cardOtherCopy.length - 1 && count === k){
						separateRealArray = separateRealArray.concat(recordArray)
					}
				}
			}
		}
		
		let result = reorderCards(separateRealArray,true)
		separateRealArray = result
		return separateRealArray
		
	}
	// 去重
	const cancelRepeat = (card:string[])=>{
		let cardArray = [] as any
		for(let i = 0;i < card.length;i++){
			let a = seachNumber(card[i],true)
			cardArray.push(a)
		}
		let numberArray = [] as any
		let realArray = [] as any
		cardArray.forEach((v:any,i:number)=>{
			if(numberArray.indexOf(v) === -1){
				numberArray.push(v)
				realArray.push(card[i])
			}
		})
		return {
			size:realArray.length,
			value:realArray
		}
	}
	// 根据cards映射出图片路径
	const mapImageUrl = (card:string)=>{
		return require(`../../assets/image/landlord/${card}.png`)
	}
	// 切片
	const sliceArray = (arr:string[],size:number)=>{
		var newArr = [];
		for (var x = 0; x < Math.ceil(arr.length / size); x++) {
		  var start = x * size;
		  var end = start + size;
		  newArr.push(arr.slice(start, end));
		}
		return newArr;
	}
	return {
		randomCards,
		reorderCards,
		sliceArray,
		mapImageUrl,
		seachRepeatSort,
		separateSeachRepeatSort,
		isConformTo,
		isStraight,
		compareCards,
	}
}
// 统计多个重复数字和单个数字
// for (let i = 0; i < card.length; i++) {
// 	let count = 0
// 	if(repeatArray.indexOf(card[i]) === -1){
// 		for(let j = 0; j < card1.length; j++){
// 			if(card[i] === card1[j]){
// 				count++
// 				if(noRepeatArray.indexOf(card[i]) === -1&&repeatArray.indexOf(card[i]) === -1){
// 					noRepeatArray.push(card[i])
// 				}
// 			}
// 			console.log(count)
// 			if(count > 1 && card[i] === card1[j]){
// 				if(count === 2){
// 					repeatArray.push(noRepeatArray[noRepeatArray.length - 1])
// 					console.log(noRepeatArray,repeatArray)
// 					noRepeatArray.splice(noRepeatArray.length - 1,1)
// 				}
				
// 				repeatArray.push(card[i])
// 				console.log(noRepeatArray,repeatArray)
// 			}
// 		}
		
// 	}
// 	if(i === card.length - 1){
// 		console.log(repeatArray,noRepeatArray)
// 	}
	
// }
// 模拟数据
// sliceResult = [
// 	['clubs1','clubs2','hearts3','clubs4','clubs5','clubs6','clubs7','clubs8','clubs9','clubs10','clubs11','clubs12','clubs13','spades2','diamonds2','hearts2'],
// 	['diamonds4','hearts2','diamonds6','diamonds7','spades9','diamonds9','diamonds10','diamonds11','diamonds12','diamonds13','clubs3','diamonds5','hearts3','hearts4','hearts5','hearts6','hearts7'],
// 	['hearts8','hearts9','hearts10','hearts11','hearts12','hearts13','spades1','spades2','spades3','spades9','clubs9','spades6','spades7','spades8','diamonds8','spades10','spades11'],
// 	['spades13','king','kinglet']
// ]